package com.autosalon.model;

import java.io.Serializable;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name="ADRESA")
public class Adresa implements Serializable, IModelClass {

	@Id
	@Column(name="ID_Ad")
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Long id;
	
	@ManyToOne(cascade = {CascadeType.PERSIST,CascadeType.MERGE,CascadeType.REFRESH})
	@JoinColumn(name = "ZAKAZNIK_ID")
	private Zakaznik zakaznik;
	
	@Column(name="ULICE", length=50, nullable=true)
	private String ulice;
	
	@Column(name="CP", nullable=false)
	private int cp;
	
	@Column(name="CO", nullable=true)
	private int co;
	
	@Column(name="PSC", length= 6, nullable=false)
	private String psc;
	
	@Column(name="MESTO", length= 50, nullable=false)
	private String mesto;
	
	@Column(name="STAT", length= 15, nullable=false)
	private String stat;
	
	@Override
	public Long getId() {
		return id;
	}

	public Zakaznik getZakaznik() {
		return zakaznik;
	}

	public void setZakaznik(Zakaznik zakaznik) {
		this.zakaznik = zakaznik;
	}

	public String getUlice() {
		return ulice;
	}

	public void setUlice(String ulice) {
		this.ulice = ulice;
	}

	public int getCp() {
		return cp;
	}

	public void setCp(int cp) {
		this.cp = cp;
	}

	public int getCo() {
		return co;
	}

	public void setCo(int co) {
		this.co = co;
	}

	public String getPsc() {
		return psc;
	}

	public void setPsc(String psc) {
		this.psc = psc;
	}

	public String getMesto() {
		return mesto;
	}

	public void setMesto(String mesto) {
		this.mesto = mesto;
	}

	public String getStat() {
		return stat;
	}

	public void setStat(String stat) {
		this.stat = stat;
	}

        @Override
        public String toString() {
            return ulice + " " + cp + ", " + mesto + ", " + psc ;
        }
	
}
